﻿using Newtonsoft.Json;
using SIE.SCADA.Common.Log;
using SIE.SCADA.StationDemo.Abstract;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;

namespace SIE.SCADA.StationDemo.SerialCommunicat
{
    class ScanerServer : WorkerBase
    {
        public override bool IsRunning { get; set; }

        protected override bool Init()
        {

            return true;
        }

        public bool Load(string fileName)
        {
            if (!File.Exists(fileName)) return false;
            string text = System.IO.File.ReadAllText(fileName);
            PortConfig = JsonConvert.DeserializeObject<StationConfig>(text);
            return true;
        }

        protected override bool Load()
        {
            return true;
        }

        public override void Start()
        {
            IsRunning = true;
        }

        public override void Stop()
        {
            IsRunning = true;
        }

        public StationConfig PortConfig
        {
            get => _PortConfig == null ? _PortConfig = new StationConfig() : _PortConfig;
            set => _PortConfig = value;
        }

        private StationConfig _PortConfig;
        private string _configFilePath;
    }
}
